package com.chenjim.glrecorder

import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.hjq.permissions.Permission
import com.hjq.permissions.XXPermissions

class PermissionActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_permission)
        XXPermissions.with(this)
            .permission(Permission.CAMERA)
            .permission(Permission.RECORD_AUDIO)
            .permission(Permission.WRITE_EXTERNAL_STORAGE)
            .request { _, all ->
                if (all) {
                    startActivity(Intent(this@PermissionActivity, MainActivity::class.java))
                } else {
                    Toast.makeText(this@PermissionActivity, "权限异常", Toast.LENGTH_LONG).show()
                }
                finish()
            }
    }
}